<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<script type="text/javascript" src="/js/main/jquery.js"></script>
<!--	<link rel="stylesheet" href="/js/main/css/comon0.css">-->
	<link rel="stylesheet" href="/layui/css/layui.css" media="all">
	<script src="/layui/layui.all.js" charset="utf-8"></script>
<!--	<script src="/js/jquery.min.js"></script>-->
	<script src="/js/core.util.js"></script>
	<style>
		.container {
			display: flex;
		}

		.left {
			width: 60%;
			padding:10px;
		}

		.right {
			width: 40%;
			padding: 10px;
			margin-left: 80px;
		}

		.loading{position:fixed; left:0; top:0; font-size:18px; z-index:100000000;width:100%; height:100%; background:#1a1a1c; text-align:center;}
		.loadbox{position:absolute; width:160px;height:150px; color: #aaa; left:50%; top:50%; margin-top:-100px; margin-left:-75px;}
		.loadbox img{ margin:10px auto; display:block; width:40px;}
	</style>
</head>
<script>
	$(window).load(function(){
		$(".loading").fadeOut()
	})

	/****/
	// $(document).ready(function(){
	// 	var whei=$(window).width()
	// 	$("html").css({fontSize:whei/20})
	// 	$(window).resize(function(){
	// 		var whei=$(window).width()
	// 		$("html").css({fontSize:whei/20})
	// 	});
	// });
</script>
<script type="text/javascript" src="/js/main/echarts.min.js"></script>
<script language="JavaScript" src="/newmain/js/bizjs/ajyj.js"></script>
<body>
<div class="loading">
	<div class="loadbox"> <img src="/js/main/picture/loading.gif"> 页面加载中... </div>
</div>

<div class="container">

	<div  id="cqyj_table_div" hidden>
		<table class="layui-hide" id="cqyj_table" lay-filter="cqyj_table"></table>
	</div>
	<div class="left">
		<table class="layui-table" id="gzzxShowTable" lay-filter="gzzxShowTable"></table>
	</div>
	<div class="right">
		<div id="echarts_ajyj" style="width: 400px;height: 400px"></div>
	</div>
</div>
<div id="layerDemo" style="margin-bottom: 0; display: none">
		<div data-method="offset" data-type="rb" id="xxtxInput"
			class="layui-btn layui-btn-normal">
		</div>
</div>
<script type="text/html" id="toolbarback">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-primary" lay-event="returnBack" >返回</button>
	</div>
</script>
<script src="/layui/layui.all.js" charset="utf-8"></script>
<script src="/js/jquery.min.js"></script>
<script src="/js/core.util.js"></script>
`<script th:inline="none">
`	// 获取token
	let token = CoreUtil.getData("access_token");
	// 地址栏转义token中的#号
	let tokenQuery = token.replace("#", "%23");
	let gzzxShowTable;
	let table = layui.table;
	let form = layui.form;
	let layer = layui.layer;
	let $ = jQuery = layui.jquery;
	let laydate = layui.laydate;
	let upload = layui.upload;
	let element = layui.element;
	let levelFirst_table;
	$(function () {
		let key = $("#key").val();
		let colsTmp = [[
			{align: 'center', field: 'swjgdm', title: '税务机关代码', hide:true},
			{totalRowText:'合计'`,align:` 'center', field: 'swjgmc', title: '机关名称',style: 'cursor:pointer;text-decoration:underline',event: 'AJYJCLICKSWJGMC'},
			{align: 'center', field: 'xy30sl', title: '<=30天',totalRow: true,event: 'FIRST_XY30SL',style: 'cursor:pointer;text-decoration:underline',},
			{align: 'center', field: 'dy30to60sl', title: '30(不含)-60天',totalRow: true,event: 'FIRST_DY30TO60SL',style: 'cursor:pointer;text-decoration:underline',},
			{align: 'center', field: 'dy60to90sl',  title: '60(不含)-90天',totalRow: true,event: 'FIRST_DY60TO90SL',style: 'cursor:pointer;text-decoration:underline',},
			{align: 'center', field: 'dy90sl', title: '>90天',totalRow: true,event: 'FIRST_DY90SL',style: 'cursor:pointer;text-decoration:underline',}
		]];
		gzzxShowTableLoad(colsTmp);
		function gzzxShowTableLoad(colsTmp) {
			levelFirst_table  =  table.render({
				elem: '#gzzxShowTable',
				id: 'gzzxShowTable',
				contentType: 'application/json',
				headers: {
					"authorization": token
				},
				totalRow:true,
				toolbar: '#toolbarback',
				cols:colsTmp,
				page: false ,// 开启分页
				url: '/attention/ajyj/tableFirstLevel', //数据接口
				method: 'POST',
				parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
					return {
						"code": res.code, //解析接口状态
						"msg": res.msg, //解析提示文本
						"count": 10000, //解析数据长度
						"data": CoreUtil.isEmpty(res.data) ? null
								: CoreUtil.paramsDecrypt(res.data)
					}
				},done: function(res, curr, count){
					var divArr = $(".layui-table-total div.layui-table-cell");
					$.each(divArr,function (index,item) {
						var _div = $(item);
						var content = _div.html();
						content = content.replace(".00","");
						_div.html(content);
					});
				}
			});
		}
	});
	layui.config({
		base: '/'
	}).extend({
		tableMerge: 'layui-ext/tableMerge/tableMerge'
	}).use(['table', 'layer', 'laydate', 'upload', 'element','tableMerge'], function () {
		table.on('tool(gzzxShowTable)', function (obj) {
			let event = obj.event;
			let swjgDm = obj.data.swjgdm;
			if (event === "XY30SL") {
				if (obj.data.xy30sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'kj');
				openXzDiv('案件预警明细(' + '<=30天' + ')');
			} else if (event === "DY30TO60SL") {
				if (obj.data.dy30to60sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'kj');
				openXzDiv('案件预警明细(' + '30(不含)-60天' + ')');
			} else if (event === "DY60TO90SL") {
				if (obj.data.dy60to90sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'kj');
				openXzDiv('案件预警明细(' + '60(不含)-90天' + ')');
			} else if (event === "DY90SL") {
				if (obj.data.dy90sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'kj');
				openXzDiv('案件预警明细(' + '>90天' + ')');
			} else if (event === "FIRST_XY30SL") {
				if (obj.data.xy30sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'sj');
				openXzDiv('案件预警明细(' + '<=30天' + ')');
			} else if (event === "FIRST_DY30TO60SL") {
				if (obj.data.dy30to60sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'sj');
				openXzDiv('案件预警明细(' + '30(不含)-60天' + ')');
			} else if (event === "FIRST_DY60TO90SL") {
				if (obj.data.dy60to90sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'sj');
				openXzDiv('案件预警明细(' + '60(不含)-90天' + ')');
			} else if (event === "FIRST_DY90SL") {
				if (obj.data.dy90sl == 0) {
					layer.msg('当前点击数量为0！', {icon: 1, time: 2000}, function () {
					});
					return false;
				}
				renderXzTable(obj,'sj');
				openXzDiv('案件预警明细(' + '>90天' + ')');
			}  else if (event === "AJYJCLICKSWJGMC") {//稽查局下钻到科室 还是理论上还是一级数据
				let colsTmp = [[
					{align: 'center', field: 'swjgdm', title: '税务机关代码', hide: true},
					{totalRowText:'合计',align: 'center', field: 'swjgmc', title: '机关名称'},
					{
						align: 'center',
						field: 'xy30sl',
						title: '<=30天',
						width: 140,
						style: 'cursor:pointer;text-decoration:underline',
						event: 'XY30SL',totalRow: true
					},
					{
						align: 'center',
						field: 'dy30to60sl',
						title: '30(不含)-60天',
						width: 140,
						style: 'cursor:pointer;text-decoration:underline',
						event: 'DY30TO60SL',totalRow: true
					},
					{
						align: 'center',
						field: 'dy60to90sl',
						width: 140,
						title: '60(不含)-90天',
						style: 'cursor:pointer;text-decoration:underline',
						event: 'DY60TO90SL',totalRow: true
					},
					{
						align: 'center',
						field: 'dy90sl',
						width: 100,
						title: '>90天',
						style: 'cursor:pointer;text-decoration:underline',
						event: 'DY90SL',totalRow: true,
					}
				]];
				table.render({
					elem: '#gzzxShowTable',
					id: 'gzzxShowTable',
					contentType: 'application/json',
					headers: {
						"authorization": token
					},
					cols: colsTmp,
					toolbar: '#toolbarback',
					totalRow:true,
					page: false,// 开启分页
					where: {swjgDm: swjgDm},
					url: '/attention/ajyj/tableFirstLevel', //数据接口
					method: 'POST',
					parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
						return {
							"code": res.code, //解析接口状态
							"msg": res.msg, //解析提示文本
							"count": 10000, //解析数据长度
							"data": CoreUtil.isEmpty(res.data) ? null
									: CoreUtil.paramsDecrypt(res.data)
						}
					},
					done: function(res, curr, count){
						var divArr = $(".layui-table-total div.layui-table-cell");
						$.each(divArr,function (index,item) {
							var _div = $(item);
							var content = _div.html();
							content = content.replace(".00","");
							_div.html(content);
						});
					}
				});
			}
		});
		function openXzDiv(title){
			layer.open({
				type : 1,
				skin : 'layui-layer-molv',
				title : title,
				area : [ '100%', '100%' ],
				shade : 0.8,
				shadeClose : true,
				content : jQuery("#cqyj_table_div"),
				btn : [ '取消' ],
			});
		}

		function renderXzTable(obj,level){
			let event = obj.event;
			let swjgDm = obj.data.swjgdm;
			let whereParams = {
				"username":"0CF9F5103FA0429B8C0224AF56A1D63B",
				"password":"0CF9F5103FA0429B8C0224AF56A1D63B",
				"serviceId":"0002",
				"param": {
					"cqyjDetailParams":{
						"swjgDm":swjgDm,
						"dayType":event,
						"datasource":"table",
						"level":level
					}
				}
			};
			let myParesDataFunction=function (res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code": res.code, //解析接口状态
					"msg": res.msg, //解析提示文本
					"count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
					"data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
				}
			};

			table.render({
				elem: '#cqyj_table',
				id: 'cqyj_table',
				contentType: 'application/json',
				headers: {
					"authorization": token
				},
				cols: [
					[
						// {type: 'checkbox', fixed: 'left'},
						{field: 'jcajbh', title: '案件编号' },
						{field: 'nsrmc', title: '纳税人名称'},
						{field: 'nsrsbh', title: '纳税人识别号'},
						{field: 'larq', title: '立案日期' },
						{field: 'jcbmmc', title: '所在科室' },
						{field: 'ajztmc', title: '案件状态'},
						{field: 'jcry', title: '检查人员'},
						{field: 'slry', title: '审理人员' },
					]
				],
				toolbar: '#toolbar',
				page: true ,// 开启分页
				where:whereParams,
				url: '/attention/ajyj/detailData', //数据接口
				method: 'POST',
				parseData: myParesDataFunction, done: function(res, curr, count){
					// 渲染完成后的回调函数
					let data = res.data; // 获取表格渲染的数据
					// 遍历表格数据，根据相应字段设置不同颜色
					for (let i = 0; i < data.length; i++) {
						let overdueDays = data[i].bh; // 获取超期天数字段
						let tr = $('#cqyj_table').next().find('tbody tr:eq(' + i + ')'); // 获取当前行对应的 tr 元素

						if (overdueDays == 1) {
							tr.css('background-color', '#91CC75');
						} else if (overdueDays == 2) {
							tr.css('background-color', '#91CC75');
						} else if (overdueDays == 3) {
							tr.css('background-color', '#91CC75');
						}else if (overdueDays == 4) {
							tr.css('background-color', 'orange');
						}else if (overdueDays == 5) {
							tr.css('background-color', 'orange');
						}else if (overdueDays == 6) {
							tr.css('background-color', 'orange');
						}else if (overdueDays == 7) {
							tr.css('background-color', '#f33636');
						}else if (overdueDays == 8) {
							tr.css('background-color', '#ADD8E6');
						}
					}
				}
			});
		}

	});
	table.on('toolbar(gzzxShowTable)', function (obj) {
		levelFirst_table.reload({
			where: { //设定异步数据接口的额外参数，任意设
				swjgDm: "",
			}
		});
	});
	function skipOpen(gnurl, gnid, title) {
		if (CoreUtil.isEmpty(gnurl) || CoreUtil.isEmpty(gnid) || CoreUtil.isEmpty(title)) {

			return false;
		} else {
			var gnurlArr = gnurl.split(",");
			var gnidArr = gnid.split(",");
			var titleArr = title.split(",");
			for (var i in gnurlArr) {
				tianzhuan(gnurlArr[i], gnidArr[i], titleArr[i])
			}
		}
	}

	function tianzhuan(gnurl, gnid, title) {
		if ($(".layui-tab-title li[lay-id]").length <= 0) {

			var title = "<span>" + title + "</span>";
			active.tabAdd(gnurl, gnid, title);

		} else {
			var isData = false;
			$.each($(".layui-tab-title li[lay-id]"),
					function () {
						if ($(this).attr("lay-id") == dataid.attr("data-id")) {
							isData = true;
						}
					})

			if (isData == false) {
				if (CoreUtil.isEmpty(dataid
						.attr("data-icon"))) {
					var title = "<span>"
							+ dataid.attr("data-title")
							+ "</span>";
					active.tabAdd(dataid.attr("data-url"),
							dataid.attr("data-id"), title);
				} else {
					var title = "<span>"
							+ dataid.attr("data-title")
							+ "</span>";
					title = '<i class="layui-icon '
							+ dataid.attr("data-icon")
							+ '"></i> ' + title;
					active.tabAdd(dataid.attr("data-url"),
							dataid.attr("data-id"), title);
				}
			}
		}

		active.tabChange(gnid);
	};

	//触发事件
	var active = {
		tabAdd: function (url, id, title) {
			if (url != "" && url != null && url != undefined) {
				window.parent.layui.element
						.tabAdd(
								'tab',
								{
									title: title,
									content: '<iframe data-frameid="'
											+ id
											+ '" frameborder="0" name="content" width="100%" src="'
											+ url + '"></iframe>',
									id: id
								})
			}
			FrameWH();//计算框架高度
		},
		tabChange: function (id) {
			//切换到指定Tab项
			window.parent.layui.element.tabChange('tab', id); //切换到：用户管理
			$("iframe[data-frameid='" + id + "']").attr("src",
					$("iframe[data-frameid='" + id + "']").attr("src"))//切换后刷新框架
		},

	};

	function FrameWH() {
		var h = $(window).height();
		$(window.parent.document).find("iframe").css("height", h + "px");
	};
</script>
</body>
</html>
